package com.example.pruebas;

import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {
	public static final String ENVIAR = "com.example.pruebas.ENVIAR";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		if (savedInstanceState == null) {
			getSupportFragmentManager().beginTransaction()
					.add(R.id.container, new PlaceholderFragment()).commit();
		}
		TextView tv3 = (TextView) findViewById(R.id.tv3);
		tv3.setText("Esperando!");
		tv3.setTextColor(Color.BLUE);

	}

	public void aceptar(View v) {
		String kuser = "jorge";
		String kpassw = "jorge";
		TextView tv3 = (TextView) findViewById(R.id.tv3);
		EditText user = (EditText) findViewById(R.id.et1);
		EditText passw = (EditText) findViewById(R.id.et2);
		if (kuser.equals(user.getEditableText().toString())) {
			if (kpassw.equals(passw.getText().toString())) {

				Intent enviar = new Intent(this, Principal.class);
				enviar.putExtra(ENVIAR, "Correcto");
				startActivity(enviar);

			} else
				tv3.setText("Error de Password");
			tv3.setTextColor(Color.RED);
		} else
			tv3.setText("Error de Usuario");
		tv3.setTextColor(Color.RED);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	/**
	 * A placeholder fragment containing a simple view.
	 */
	public static class PlaceholderFragment extends Fragment {

		public PlaceholderFragment() {
		}
	}

}
